
// write the special six-byte code to turn off software data protection
void disableWriteProtection29() {
  digitalWrite(CE, LOW);
  write_mode();                            // set data bus pins as output
  //reset
  setByte (0x0000, 0xf0);
  delay(1);
  setByte (0x5555, 0xaa);                     // write code sequence
  setByte (0x2aaa, 0x55);
  setByte (0x5555, 0x80);
  setByte (0x5555, 0xaa);
  setByte (0x2aaa, 0x55);
  setByte (0x5555, 0x20);
  digitalWrite(CE, LOW);
  read_mode();                             // release data bus (set as input)
  delay(100);                                  // wait write cycle time
  Serial.println("ok");
}

// write the special three-byte code to turn on software data protection
void enableWriteProtection29() {
  digitalWrite(CE, LOW);
  write_mode();                            // set data bus pins as output
  //reset
  setByte (0x0000, 0xf0);
  delayMicroseconds(1);
  setByte (0x5555, 0xaa);                     // write code sequence
  setByte (0x2aaa, 0x55);
  setByte (0x5555, 0xa0);
  digitalWrite(CE, HIGH);
  read_mode();                             // release data bus (set as input)
  delay(100);                                  // wait write cycle time
}
